-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added bulk mode UDP #75
base: master
Are you sure you want to change the base?
Conversation
class udp | ||
: public std::enable_shared_from_this<udp> | ||
, public isocket | ||
class udp_base |
Check warning
Code scanning / CodeQL
Non-virtual destructor in base class
/* TRACE - enable if necessary for development | ||
for (int i = 0; i < res; ++i) | ||
{ | ||
std::cout << "[" << (*bufsizes[i]) << "]"; | ||
} | ||
std::cout << std::endl; | ||
*/ |
Check notice
Code scanning / CodeQL
Commented-out code
if (val[0] == "bulk") | ||
::xtransmit::g_udp_mode_bulk = true; | ||
return true; | ||
}, | ||
"UDP mode: simple or bulk [Linux only]"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To detect possible typos (if returning false
results in an error):
else if (val[0] != "simple")
return false;
udp(const UriParser &src_uri); | ||
~udp(); | ||
udp_base(const UriParser &src_uri); | ||
~udp_base(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
~udp_base(); | |
virtual ~udp_base(); |
while (!m_blocking_mode) | ||
{ | ||
fd_set set; | ||
timeval tv; | ||
FD_ZERO(&set); | ||
FD_SET(m_bind_socket, &set); | ||
tv.tv_sec = 0; | ||
tv.tv_usec = 10000; | ||
const int select_ret = ::select((int)m_bind_socket + 1, &set, NULL, &set, &tv); | ||
|
||
if (select_ret != 0) // ready | ||
break; | ||
|
||
if (timeout_ms >= 0) // timeout | ||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to block if there is a cached buffer to read.
Added "bulk mode" UDP reader. This is implemented as a separate
socket::mudp
class which usesrecvmmsg
for reading multiple packets if available.Packets are stored in a local buffer and are returned from cache. The call to the system function refills the cache.
Available only on Linux.
You need to enable it (instead of the standard UDP reader) by
--udp-mode bulk
option.